package com.labreeze.spring.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.stereotype.Component;

@Component("test02")
public class Test02 {

	@Autowired
	private JdbcTemplate jdbcTemplate;
	

	public void query2(){
		String sql ="select * from tt_user";
		jdbcTemplate.query(sql,  new RowCallbackHandler() {
			
			public void processRow(ResultSet rs) throws SQLException {
				// TODO Auto-generated method stub
				System.out.println("id:"+rs.getInt("id"));
				System.out.println("name:"+rs.getString("name"));
			}
		});
		
		
	}
	

	public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}
	
	
	
}
